/*
 *  最小子矩阵
 * */

#include <iostream>
using namespace std;

const int N = 510;

int n, m, k;
int s[N][N];
int main()
{
    scanf("%d%d%d", &n, &m, &k);

    long long res = 0;


    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            scanf("%d", &s[i][j]);
            s[i][j] += s[i - 1][j];
        }
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = i; j <= n; ++j) {
            for (int l = 1, r = 1, sum = 0; r <= m; ++r) {
                sum += s[j][r] - s[i - 1][r];
                while (sum > k) {
                    sum -= s[j][l] - s[i - 1][l];
                    l++;
                }
                // 以右端点为界的子矩阵的个数
                res += r - l + 1;
            }
        }
    }

    printf("%lld\n", res);
    return 0;
}